layui.use(['layer','jquery'], function(){
  var layer = layui.layer
  ,$ = layui.jquery;
  layer.ready(function(){
    $(window).scroll(function(){
      if($(window).scrollTop()>100){
        $('#back').fadeIn(200);
      }else{
        $('#back').fadeOut(200);
      }
    });
  	$('#back').on('click',function(){
      $('html,body').animate({scrollTop:0},500);
  	});
  	$('.layui-qrcode').on('click', function(){
      layer.open({
      	type: 1, 
      	title: false,
      	shadeClose: true,
      	content: '<div class="qrcode"><img src="/statics/images/code.png" /><p class="layui-text">扫一扫，用手机打开看美图！</p></div>'
      });    
  	});
  	$('.layui-app').on('click', function(){
  	  layer.alert('APP还在开发中......！',{
  	 	skin: 'layui-tips',
  	  });
  	});
    $('.layui-search').on('click', function(){
      layer.open({
        type: 1, 
        title: false,
        shadeClose: true,
        closeBtn: 0,
        resize: false,
        area: 'auto',
        maxWidth: '520px',
        content: "<form action=\"/search/\" target=\"_blank\"><input autocomplete=\"off\" placeholder=\"输入关键词，回车搜索\" type=\"text\" name=\"q\" class=\"layui-open-input\" lay-verify=\"q\"></form>"
      });
    });
  });
});